<template>
  <div id="about">
    <el-card class="box-card">
      <template #header>
        <div class="card-header">
          <div>关于我</div>
          <div class="title">{{ store.state.centerData[0].motto || '' }}</div>
        </div>
      </template>
      <div class="item">
        昵称：{{
          store.state.centerData[0] ? store.state.centerData[0].uname : ''
        }}
      </div>
      <div class="item">
        电话：{{
          store.state.centerData[0] ? store.state.centerData[0].tel : ''
        }}
      </div>
      <div class="item">
        微信：{{
          store.state.centerData[0] ? store.state.centerData[0].wechat : ''
        }}
      </div>
      <div class="item">
        Q Q：{{ store.state.centerData[0] ? store.state.centerData[0].qq : '' }}
      </div>
      <el-divider />
      <div class="mapTitle">我现在的位置: {{ address }}</div>
      <AboutMap
        v-if="store.state.centerData[0]"
        :latitude="latitude"
        :longitude="longitude"
        @addressData="addressData"
      ></AboutMap>
    </el-card>
  </div>
</template>

<script lang="ts" setup>
import { inject, defineAsyncComponent, ref } from 'vue'
const store: any = inject('store')
const address = ref<string>('未获取到')
const AboutMap = defineAsyncComponent(
  () => import('@/components/about/AboutMap.vue')
)
let [longitude, latitude] = store.state.centerData[0].location.split(',')
const addressData = (addr: string) => {
  address.value = addr
}
</script>

<style lang="scss" scoped>
.mapTitle {
  text-align: center;
  font-size: 16px;
  font-weight: 900;
  color: #49b1f5;
  letter-spacing: 2px;
  margin-bottom: 10px;
}
#about {
  min-height: 500px;
  max-width: 1200px;
  margin: auto;
}

.title {
  color: #888;
  font-weight: 700;
  letter-spacing: 3px;
  font-size: 12px;
}

.card-header {
  display: flex;
  justify-content: center;
  flex-direction: column;
  color: #888;
  font-weight: 900;
  letter-spacing: 3px;
  font-size: 25px;

  > div:nth-child(1) {
    width: 100%;
    text-align: center;
  }

  > div:nth-child(2) {
    margin-top: 10px;
    text-align: right;
  }
}

.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
  padding-left: 20px;
  user-select: text;
}

.box-card {
  margin-top: -50px;
  color: #888;
  font-weight: 400;
  font-size: 12px;
}

@media (max-width: 760px) {
  .card-header {
    > div:nth-child(2) {
      text-align: left;
    }
  }
  .mapTitle {
    text-align: left;
  }
}
</style>
